import { ImageResponse } from 'next/og'; import { Fallback, Wallpaper } from '@/components/brand/og'; import { api, apiD1, safe } from '@/lib/api'; import { fmtInt, num } from '@/lib/format'; import { SITE_NAME, typeLabel } from '@/lib/site'; export const runtime = 'nodejs'; export const alt = `Organization on ${SITE_NAME}`; export const size = { width: 1200, height: 630 }; export const contentType = 'image/png'; /** Per-organization Open Graph image: wallpaper with the live footprint counters (models · families · papers · announcements). */ export default async function CompanyOgImage({ params }: { params: Promise<{ slug: string }> }) { const { slug } = await params; const d = await safe(api.entityOfType('companies', slug)); if (!d) return new ImageResponse(, { ...size }); const [models, fams, papers] = await Promise.all([safe(api.models({ org: d.slug, limit: 1 })), safe(apiD1.families({ org: d.slug, limit: 1 })), safe(api.papers({ org: d.slug, limit: 1 }))]); const a = d.attributes ?? {}; const counters: [string, string][] = []; const m = num(models?.total) ?? num(d.model_count) ?? num(d.models?.total); if (m !== null) counters.push(['Models', fmtInt(m)]); const f = num(fams?.total); if (f !== null && f > 0) counters.push(['Families', fmtInt(f)]); const p = num(papers?.total) ?? num(d.paper_count); if (p !== null && p > 0) counters.push(['Papers', fmtInt(p)]); if (typeof a.country === 'string') counters.push(['Country', a.country]); if (a.founded) counters.push(['Founded', String(a.founded).slice(0, 4)]); const eyebrow = typeof a.org_kind === 'string' && a.org_kind.toLowerCase() !== typeLabel(d.entity_type).toLowerCase() ? `${typeLabel(d.entity_type)} · ${a.org_kind}` : typeLabel(d.entity_type); return new ImageResponse(, { ...size }); }